#include "stm32f10x.h"                  // Device header
#include "BalanceCar_Set.h"

// PWM配置数组 (支持最多4个电机)
PWM_Channel_t PWM_Channels[] = {		
    // 电机1: TIM1 CH4 (PA11)                                       
    {TIM1, TIM_Channel_4, TIM_SetCompare4, GPIOA, GPIO_Pin_11, 1},	// 左电机
                                                                 
    // 电机2: TIM1 CH1 (PA8)										// 1高级定时器,0通用定时器
    {TIM1, TIM_Channel_1, TIM_SetCompare1, GPIOA, GPIO_Pin_8, 1}	// 右电机
};
// 电机数量
const uint8_t PWM_CHANNEL_COUNT = sizeof(PWM_Channels)/sizeof(PWM_Channels[0]);
	
// 编码器配置数组
Encoder_t Encoders[] = {
    // 编码器A: TIM2 (PA0-PA1)
    {TIM2, GPIOA, GPIO_Pin_0, GPIO_Pin_1},	// 左电机
    
    // 编码器B: TIM4 (PB6-PB7)
    {TIM4, GPIOB, GPIO_Pin_6, GPIO_Pin_7}	// 右电机
};
// 编码器数量
const uint8_t ENCODER_COUNT = sizeof(Encoders)/sizeof(Encoders[0]);
	
// TB6612配置数组
MotorCtrl_t MotorCtrls[] = {
    // 电机A: IN1(PB12), IN2(PB13)
    {GPIOB, GPIO_Pin_13, GPIO_Pin_12},// 左电机
                                      
    // 电机B: IN1(PB14), IN2(PB15)      
    {GPIOB, GPIO_Pin_14, GPIO_Pin_15} // 右电机
};
// 编码器数量
const uint8_t MOTOR_CTRL_COUNT = sizeof(MotorCtrls)/sizeof(MotorCtrls[0]);

PID_t LeftPID[] = {			// 左PID
	{.Target = 0.5, .Kp = 3.7, .Ki = 0.1, .Kd = 0.2, .OutMax = 100, .OutMin = -100},// 内PID
	{.Target = 0, .Kp = 0, .Ki = 0, .Kd = 0, .OutMax = 10, .OutMin = -10}// 外PID
};

PID_t RightPID[] = {		// 右PID
	{.Target = 0.5, .Kp = 3.7, .Ki = 0.1, .Kd = 0.2, .OutMax = 100, .OutMin = -100},// 内PID
	{.Target = 0, .Kp = 0, .Ki = 0, .Kd = 0, .OutMax = 10, .OutMin = -10}// 外PID
};

